package com.weetop.cfw.home_page.adapter;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.weetop.cfw.R;
import com.weetop.cfw.bean.GeneralCodeTableBean;
import com.weetop.cfw.home_page.activity.PlantSalePublishActivity;
import com.weetop.cfw.home_page.activity.PublishActivity;

import java.util.ArrayList;
import java.util.List;

public class IndustryDataDialog1 extends Dialog {
    TextView cancel, content, complete;
    BuildTypeAdapter buildTypeAdapter;
    ListView listView;
    public List<Boolean> list1 = new ArrayList();
    List<GeneralCodeTableBean.DataBean> kindDataBeanList;

    public IndustryDataDialog1(final Context context, List<GeneralCodeTableBean.DataBean> kindDataBeanList, final ArrayList<String> mList, ArrayList<Boolean> list1, String str) {
        super(context, R.style.promptDialog);
        setContentView(R.layout.dialog_build_type);
        this.kindDataBeanList=kindDataBeanList;
        cancel = findViewById(R.id.cancel);
        content = findViewById(R.id.content);
        complete = findViewById(R.id.complete);
        listView = findViewById(R.id.listView);
        content.setText(str);
        buildTypeAdapter = new BuildTypeAdapter(context, mList, list1);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        complete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                buildTypeAdapter.list1
                String str="";
                ArrayList<String> selectList = new ArrayList();
                ArrayList<String> idList = new ArrayList();
                for (int i = 0; i < mList.size(); i++) {
                    if (buildTypeAdapter.list1.get(i)) {
                        selectList.add(kindDataBeanList.get(i).getCodename());
                        idList.add(kindDataBeanList.get(i).getCodeid()+"");
                    }
                }
                ((PlantSalePublishActivity) context).getSelectList1(selectList,idList);
                dismiss();
            }
        });
        listView.setAdapter(buildTypeAdapter);
        buildTypeAdapter.notifyDataSetChanged();
    }

    public List<Boolean> getSelectList() {
        return list1;
    }
}
